'use strict'

const Service = require('egg').Service

class ActionTokenService extends Service {
    //根据username 生成token
    async create(username) {
        const { ctx } = this
        return ctx.app.jwt.sign({
            data: {
                username: username
            },
            exp: Math.floor(Date.now() / 1000) + (60 * 60 * 24 * 7) //失效时间
        }, ctx.app.config.jwt.secret)
    }


}

module.exports = ActionTokenService